package my.tests;

import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import demo.codeanalyzer.processor.CodeAnalyzerController;
import demo.codeanalyzer.processor.CodeGeneratorFactory;
import demo.codeanalyzer.processor.RdfCodeGenerator;
import junit.framework.TestCase;

public class RDFSample extends TestCase {
	public void _testRDFCodeGenerator() throws Exception {
		File motorVehicle = new File("./testcode/MotorVehicle.java");
		File passengerVehicle = new File("./testcode/PassengerVehicle.java");
		File truck = new File("./testcode/Truck.java");
		File van = new File("./testcode/Van.java");
		// File namespaceMappingAnnotation = new File(
		// "./testcode/NamespaceMapping.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.rdfCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(motorVehicle,
				passengerVehicle, truck, van));
	}

	public void _testOwlSubClasses() throws Exception {
		File continent = new File("./testcode/Truck.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(continent));
	}

	public void _testOWLCodeGenerator() throws Exception {
		File continent = new File("./testcode/Continent.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(continent));
	}

	public void _testOWLDataProperty() throws Exception {
		File continent = new File("./testcode/VintageYear.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(continent));
	}

	public void _testOWLProperty() throws Exception {
		File continent = new File("./testcode/Wine.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(continent));
	}

	public void _testOWLNameSpaces() throws Exception {
		File nameSpaces = new File("./testcode/Namespaces.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(nameSpaces));
	}

	public void _testOwlClass() throws Exception {
		File articleLink = new File("./testcode/ArticleLink.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(articleLink));
	}

	public void _testMarketTimeModule() throws Exception {
		File articleLink = new File("./testcode/MarketTimeModule.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(articleLink));
	}

	public void _testBullishBearishModule() throws Exception {
		File articleLink = new File("./testcode/BearishBullishModule.java");
		File bullishArticle = new File("./testcode/BearishArticle.java");
		File bearishArticle = new File("./testcode/BullishArticle.java");
		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(articleLink,
				bullishArticle, bearishArticle));
	}

	public void _testCommonFooter() throws Exception {
		File commonFooterModule = new File("./testcode/CommonFooterModule.java");
		File commonFooterItem = new File("./testcode/CommonFooterItem.java");
		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(commonFooterModule,
				commonFooterItem));
	}
	
	public void testMarketSummary() throws Exception {
		File marketSummaryModule = new File("./testcode/MarketSummaryModule.java");
		File marketSummary = new File("./testcode/MarketSummary.java");
		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(marketSummaryModule,
				marketSummary));
	}


	public void _testOWLEnumeration() throws Exception {
		File continents = new File("./testcode/Continents.java");

		CodeAnalyzerController controller = new CodeAnalyzerController(
				CodeGeneratorFactory.owlCodeGenerator());
		controller.invokeProcessor(commaSeparatedList(continents));
	}

	public void _testname() throws Exception {
		// Pattern enumPattern =
		// Pattern.compile(".*\\s*\\w+\\s+Enum\\s+\\w+\\s*[{]");
		// assertTrue(enumPattern.matcher(" public Enum Dude {").matches());
		Pattern enumPattern = Pattern
				.compile("/[*](.|\\s)*[*]/(.*)/[*](.|\\s)*[*]/");
		String toTest = "/*public static final*/ Africa /* = new Continents() */";
		Matcher matcher = enumPattern.matcher(toTest);
		assertTrue(matcher.find());
		assertEquals(matcher.group(2), " Africa ");
		assertTrue(matcher.matches());

	}

	private String commaSeparatedList(File... tobeSeparated) {
		StringBuilder result = new StringBuilder();
		result.append(tobeSeparated[0]);
		for (int i = 1; i < tobeSeparated.length; i++) {
			result.append(",").append(tobeSeparated[i].getAbsolutePath());
		}
		return result.toString();
	}
}
